from tkinter import ttk


class NavigationBar(ttk.Frame):
    def __init__(self, parent):
        super().__init__(parent)
        self.configure(padding=(0,2))
        self.buttons = {}

        # 添加导航按钮
        for text, tool_type in [("PDF工具", "pdf"), ("图像工具", "image")]:
            btn = ttk.Button(
                self,
                text=text,
                width=15,
                command=lambda t=tool_type: self._on_button_click(t),
                bootstyle="primary-outline",
                padding=(5, 5)  # 调整内边距，使其更接近卡片标题
            )
            btn.pack(pady=8, fill="x")  # 调整垂直间距
            self.buttons[tool_type] = btn

    def _on_button_click(self, tool_type):
        if hasattr(self, 'callback') and callable(self.callback):
            self.callback(tool_type)

    def on_button_click(self, callback):
        """绑定外部回调函数"""
        self.callback = callback
